package org.example.booksmanagementsystem.model;

import lombok.Data;

@Data
public class PageRequest {
    // 请求的页数
    private int currentPage=1;

    //请求的该页条数
    private int pageSize=10;

    //开始的索引
    private int offset;

    public PageRequest(int currentPage){
        this.currentPage = currentPage;
        this.offset=(this.currentPage-1)* this.pageSize;
    }

    public PageRequest(){
        this.offset=(this.currentPage-1)*this.pageSize;
    }

    public PageRequest(int currentPage, int pageSize){
        this.currentPage=currentPage;
        this.pageSize=pageSize;
        this.offset=(this.currentPage-1)* this.pageSize;

    }

    //获取开始的索引
    public int getOffset(){
        return (this.currentPage-1)* this.pageSize;
    }
}
